package com.neu.admin;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neu.doc.AdminDashbordController_detail;
import com.neu.domain.ShoppingUserExample;
import com.neu.service.ShoppingGoodsProductService;
import com.neu.service.ShoppingGoodsService;
import com.neu.service.ShoppingOrderService;
import com.neu.service.ShoppingUserService;
import com.neu.util.ResponseUtil;

import io.swagger.annotations.ApiOperation;

import java.util.HashMap;
import java.util.Map;

@Validated
@RestController
@CrossOrigin
@RequestMapping("/admin/dashboard")
public class AdminDashbordController {
    private final Log logger = LogFactory.getLog(AdminDashbordController.class);

    @Autowired
    private ShoppingUserService userService;
    @Autowired
    private ShoppingGoodsService goodsService;
    @Autowired
    private ShoppingGoodsProductService productService;
    @Autowired
    private ShoppingOrderService orderService;
   @ApiOperation(value="后台管理首页", notes="后台管理首页信息",response = AdminDashbordController_detail.class)
   @GetMapping("")
    public Object info() {
    	int user = userService.count();
    	int goods = goodsService.count();
    	int product= productService.count();
    	int order = orderService.count();
		Map<String, Integer> map = new HashMap<>();
		map.put("userTotal", user);
		map.put("goodsTotal", goods);
		map.put("productTotal", product);
		map.put("orderTotal",order);
//    	service.count 方法
		return ResponseUtil.ok(map);
    }

}
